<template>
	<div id="">
		<el-table v-loading="loading" ref="multipleTable" :data="list" style="width: 100%" size="small"  border
			                row-key="id" :tree-props="{children: 'children'}" :indent="20">
					<el-table-column label="ID" prop="id"></el-table-column>
			        <el-table-column label="名称" prop="name"></el-table-column>
			        <!-- <el-table-column label="ID" v-if="false"></el-table-column> -->
			        <el-table-column label="用户名" prop="username"></el-table-column>

			        </el-table-column>
	
			        <el-table-column label="操作" align="center" width="200">
			          <template slot-scope="scope" >
			            <el-button type="success" v-if="scope.row.username != 'admin' && scope.row.username != user.username" size="mini" @click="editHandle(scope.row)" icon="el-icon-edit" >修改
			            </el-button>
						<el-button type="success" v-else disabled size="mini" @click="editHandle(scope.row)" icon="el-icon-edit" >修改
						</el-button>
					   <el-button type="danger" v-if="scope.row.username != 'admin' && scope.row.username != user.username" size="mini" @click="deleteHandle(scope.row)" icon="el-icon-delete">删除
					   </el-button>
					   <el-button type="danger"v-else disabled size="mini" @click="deleteHandle(scope.row)" icon="el-icon-delete">删除
					   </el-button>				
			          </template>
			
			        </el-table-column>
		</el-table>	
	</div>
</template>

<script>
		import UserApi from '@/api/user.js'
		import {
		  getSessionStorage
		} from '@/utils/base'
		export default {

			data() {
				return {
					list: [],
					user:'',
					loading: true
				}
			},
			created () {
				this.user = getSessionStorage('userInfo')
				console.log(123)
				console.log(this.user)
				// 获取列表
				UserApi.getUserList().then((res)=>{
					// console.log(res)
					this.list = res.data.data
					

					this.loading=false
				})

			},
			methods:{
				editHandle(row){
					console.log(row)
					return
					let params = [true,row.id]
					this.$emit('editClick',params)
					// this.$emit('changeEdit',true)
				},
				deleteHandle(row){
					return
					let params = {'id':row.id}
					this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
					  confirmButtonText: '确定',
					  cancelButtonText: '取消',
					  type: 'warning'
					}).then(() => {
						AuthApi.del(params).then((res)=>{
							let type = res.data.code == 1?'success':'error';
							this.$message({
							  message: res.data.msg,
							  type: type
							});
							if(res.data.code == 1){
								this.$router.go(0)
							}
							// this.$router.go(0)
							
						})
					})		

				}
			}
		}
	
</script>

<style>
</style>
